package com.crm.service.impl.customerManager;


import com.crm.common.model.Enum.StatusCodeEnum;
import com.crm.dao.mapper.customerManager.ExchangeMapper;
import com.crm.dao.mapper.customerManager.ExchangeProductMapper;
import com.crm.model.entity.customerManager.Exchange;
import com.crm.model.entity.customerManager.ExchangeExample;
import com.crm.model.entity.customerManager.ExchangeProduct;
import com.crm.model.entity.customerManager.ExchangeProductExample;
import com.crm.service.customerManager.CustomerExchangeDbService;
import com.crm.service.customerManager.CustomerExchangeProductDbService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * 兑换产品表
 * @ Author ：baijian
 * @ Date   ：2021/5/7 14:41
 */
@Service
public class CustomerExchangeProductDbServiceImpl implements CustomerExchangeProductDbService {

    @Autowired
    private ExchangeProductMapper exchangeProductMapper;

    /**
     * 产品兑换状态  兑换前  1  兑换后 2
     * @param exchangeId 兑换id
     * @param exchangeType 产品兑换状态--1:兑换前;2:兑换后
     * @return
     */
    @Override
    public List<ExchangeProduct> exchangeProductList(String exchangeId, int exchangeType) {
        ExchangeProductExample exchangeProductExample = new ExchangeProductExample();
        ExchangeProductExample.Criteria criteria = exchangeProductExample.createCriteria();
        criteria.andExchangeIdEqualTo(exchangeId);
        criteria.andExchangeTypeEqualTo(exchangeType);
        criteria.andDeleteStatusEqualTo(Short.parseShort(String.valueOf(StatusCodeEnum.NORMAL_CODE.getState())));
        List<ExchangeProduct> list = exchangeProductMapper.selectByExample(exchangeProductExample);
        return list;
    }
}
